﻿using System;
using OpenPop.Mime;

namespace ggHD.Domain.BizObj
{
    public partial class RawMail 
    {
        public RawMail()
        {
        }

        public RawMail(Message msg)
        {
            RawData = msg.RawMessage;
            this.DateLoaded = DateTime.Now;
            this.DateSent = msg.Headers.DateSent;
            this.FromAddress = msg.Headers.From.Address;
            this.FromName = msg.Headers.From.DisplayName;
            
            var mId = msg.Headers.MessageId;
            this.MsgId =  string.IsNullOrWhiteSpace(mId)? msg.Headers.DateSent+" " +msg.Headers.From.Address:mId;
        }
    }
}
